package com.lambkit.module.admin;

import com.jfinal.aop.Clear;
import com.lambkit.distributed.node.NodeManager;
import com.lambkit.distributed.node.info.NodeBuilder;
import com.lambkit.web.controller.LambkitController;

public class AdminController extends LambkitController {

	public void index() {
		//user
		if(hasUser()) {
			set("auth", getUser());
		}
		//node
		NodeBuilder nb = new NodeBuilder();
		setAttr("node", nb.resetNodeInfo(NodeManager.me().getNode()));
		int size = 0;
		if(NodeManager.me().getNodeTable()!=null) {
			setAttr("ntable", NodeManager.me().getNodeTable().getValues());
			size = NodeManager.me().getNodeTable().getNodes().size();
		}
		setAttr("ntsize", size);
		setAttr("adminUrl", AdminManager.me().getWebConfig().getUrl());
		renderTemplate(AdminManager.me().getTemplatePath() + "/index.html");
	}
	
	@Clear
	public void login() {
		renderTemplate(AdminManager.me().getTemplatePath() + "/login.html");
	}
	
	public void portal() {
		renderTemplate(AdminManager.me().getTemplatePath() + "/portal.html");
	}
	
	public void dashboard() {
		renderTemplate(AdminManager.me().getTemplatePath() + "/dashboard.html");
	}
	
}
